import {
	app,
	BrowserWindow,
	Menu,
	ipcMain
} from 'electron'

//禁用GPU加速。
app.disableHardwareAcceleration()

// ipcMain.on('min',e=> mainWindow.minimize());

// ipcMain.constructor('max',e=>{
// 	if(mainWindow.isMaximized()){
// 		mainWindow.unmaximize()
// 	}else{
// 		mainWindow.maximize()
// 	}
// })

// ipcMain.on('close',e=>mainWindow.close());


/**
 * Set `__static` path to static files in production
 * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
 */
if (process.env.NODE_ENV !== 'development') {
	global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\')
}

let mainWindow
const winURL = process.env.NODE_ENV === 'development' ?
	`http://localhost:9080` :
	`file://${__dirname}/index.html`

function createWindow() {
	/**
	 * Initial window options
	 */
	Menu.setApplicationMenu(null);

	mainWindow = new BrowserWindow({
fullscreenable:true,
		height: 735,
		useContentSize: true,
		width: 1160,
		//electron跨域
		webPreferences: {
			webSecurity: false
		},
		// frame: false, //添加这一行采用无边框窗口

	})

	mainWindow.loadURL(winURL)

	mainWindow.on('closed', () => {
		mainWindow = null
	})
}

app.on('ready', createWindow)

app.on('window-all-closed', () => {
	if (process.platform !== 'darwin') {
		app.quit()
	}
})

app.on('activate', () => {
	if (mainWindow === null) {
		createWindow()
	}
})
